package 多线程.Lambda推导在Thread的应用;

/**
 * lambda推导
 * （lambda是为了避免内部类定义过多）
 */
public class LambdaTest01 {
    //2.静态内部类
    static class like2 implements ILike {
        @Override
        public void lambda() {
            System.out.println("i like lambda2");
        }
    }

    public static void main(String[] args) {
        ILike like = new like();
        System.out.println();;
        like = new like2();
        like.lambda();

        //3.匿名内部类
        like = new ILike() {
            @Override
            public void lambda() {
                System.out.println("lambda3");
            }
        };
        like.lambda();
        //4.lambda
        like = () -> {
            System.out.println("lambda3");
        };

        like.lambda();
    }
}

interface
ILike {
    void lambda();
}

//1.外部类
class like implements ILike {
    @Override
    public void lambda() {
        System.out.println("i like lambda");
    }
}
